﻿using Finbook.ConsoleApp.Interceptors;
using MongoDB.Bson.Serialization.Attributes;
using System;
using System.Collections.Generic;
using System.Text;

namespace Finbook.ConsoleApp.Models
{
    [BsonIgnoreExtraElements]
    public class Person
    {
        public Person()
        {
            CreateTime = DateTime.Now;
        }
        public string Name { get; set; }
        public int Age { get; set; }
        public DateTime CreateTime { get; set; }
        [CustomInterceptor]
        public virtual void SayHi(string name)
        {
            Console.WriteLine($"Hi,{name}");
        }
        [HelloFallbackInterceptor("SayHelloFallback")]
        public virtual void SayHello(string name)
        {
            //Console.WriteLine($"Hello,{name}");
            throw new Exception();
        }
        public virtual void SayHelloFallback(string name)
        {
            Console.WriteLine($"调用{nameof(SayHello)}失败了！");
        }
        [HystrixCommandInterceptor(FallbackMethod =nameof(SayHelloFallback))]
        public virtual void SayGoodBye(string name)
        {
            throw new Exception();
            Console.WriteLine($"{name},GoodBye.");
        }
    }
}
